package com.dingding.service.common.core.dao.impl;

import java.math.BigDecimal;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.Userdetail;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.service.common.core.dao.IUserDetailDao;

@Component("userDetailDao")
public class UserDetailDaoImpl extends BaseDaoImpl<Userdetail> implements IUserDetailDao {

	/**
	 * 
	 * @Title: addUserDetail
	 * @Description: 保存到用户详情表
	 * @param tellphone 手机号
	 * @param userLoginId 用户ID
	 * @author CHEHAUNBO
	 * @return
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void addUserDetail(String tellphone, String userLoginId) {

		Userdetail userdetail = new Userdetail();
		// 为用户详情表设置主键
		userdetail.setUdId(ToolUtil.getUid());
		// 用户登录ID
		userdetail.setLoginId(userLoginId);
		// 用户昵称
		userdetail.setNickName("叮叮小伙伴");
		// 用户性别
		userdetail.setSex(1);
		// 用户手机号码
		userdetail.setTellphone(tellphone);
		// 用户头像设置
		userdetail.setUserAvatar("header_2x.png");
		// 总搭乘
		userdetail.setTotalTake(new BigDecimal(0));
		// 总接程
		userdetail.setTotalWeldingProcess(new BigDecimal(0));
		// 总搭乘次数
		userdetail.setTotalTakeNumber(0);
		// 总接乘次数
		userdetail.setTotalWeldingProcessNumber(0);
		try {
			// 向用户详情表中插入一条记录
			super.save(userdetail);
		} catch (Exception e) {
			log.error("添加用户详细信息出现异常！", e);
		}

	}

}
